package com.example.shopping_web_back.mapper;

import com.example.shopping_web_back.pojo.ReceivePlace;
import com.example.shopping_web_back.pojo.Result;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ReceivePlaceMapper {

    @Select("select * from shoppingweb.receiveplace where customer_name=#{customerName}")
    List<ReceivePlace> searchReceivePlace(String customerName);

    @Select("select * from shoppingweb.receiveplace where customer_name=#{customerName} and email=#{email} and name=#{name} and telephone=#{telephone} and province=#{province} and district=#{district} and city=#{city} and address=#{address}")
    ReceivePlace findReceivePlace(ReceivePlace receivePlace);

    @Insert("INSERT INTO shoppingweb.receiveplace (name, province, city, district, address, customer_name, telephone, email) VALUE "
            + "(#{name}, #{province}, #{city}, #{district}, #{address}, #{customerName}, #{telephone}, #{email})")
    void addReceivePlace(ReceivePlace receivePlace);

    @Update("update shoppingweb.receiveplace set name=#{newReceivePlace.name}, province=#{newReceivePlace.province}, city=#{newReceivePlace.city}, district=#{newReceivePlace.district}, address=#{newReceivePlace.address}, telephone=#{newReceivePlace.telephone}, email=#{newReceivePlace.email}"
            + " where id=#{id1}")
    void updateReceivePlace(Integer id1, ReceivePlace newReceivePlace);

    @Delete("delete from shoppingweb.receiveplace where customer_name=#{customerName} and email=#{email} and name=#{name} and telephone=#{telephone} and province=#{province} and district=#{district} and city=#{city} and address=#{address}")
    void deleteReceivePlace(ReceivePlace receivePlace);
}
